Repository navigation
Inkling 2 Mini on Metal: wide prompt chunks take the routed experts on turned tiles, 16 weight rows by 32 of an expert's pairs an op - #4649
Conversation
aefb063 to
c41911e
Compare
|
Sorry for the noise: this was closed automatically when #4387 landed on main and its base branch was removed. It is reopened and now targets
|
…in the fewest 1,024-key folds a slot
…uffers, independent launches side by side
… a row's sums never depend on its chunk
…mdgroup folds the partial sums itself
…de between a prompt's chunks
…y for up to 16 rows
… the prompt kernel, a tile of keys a chunk
…ps in the scratch, so a stream's cache stages a window only
… cap while replies decode
…s from the cache, with no staging between
…16 weight rows by 32 of an expert's pairs an op
84ab2c6 to
69863f2
Compare
|
Thanks @sethforprivacy. #4649 is #4645 plus one commit, Exactness
Stale against today's main Main now reports each kernel choice through TF_EXPLAIN ( Repo checks we ran on this branch:
The M5 check we'd like to see:
|
What this changes
Before: a tensor-unit tile of the routed experts is 32 weight rows by 16 of an expert's pairs, at every chunk width. After: a chunk of more than 512 rows takes the same products on tiles turned the other way, 16 weight rows by 32 of the expert's pairs an op. A 1,024-row chunk gives an expert 64 pairs on average, so a 32-pair band is full, and a block of weights is decoded once for 32 pairs where it was decoded once for 16.
A 1,024-row prompt chunk at 16K tokens of context goes from 428 to 403 ms of GPU time, and a 45K-token prompt from 2,078 to 2,212 tok/s served. Same bits.
This is a proposal on top of #4387, opened as a draft.
3e0e9bcb83, then Inkling 2 Mini on Metal: #4387's native build compiles, its norms write their output, and concurrent streams equal solo #4446, Inkling 2 Mini on Metal: experts, gates, router, depth mix, combine, row batching, attention chunks and a concurrent forward (1,159 to 14 ms a row on M5 Ultra) #4448, Inkling 2 Mini on Metal: routed experts on the M5 tensor units at every width (16 rows 49 to 36 ms, 64 rows 138 to 84 ms) #4523, Inkling 2 Mini on Metal: fill a prompt a chunk a call, so other streams keep decoding (a reply's longest stall beside a 32K fill 36.3 s to 0.4 s) #4608, Inkling 2 Mini on Metal: a round's logits in one pass of the vocabulary (one drafted stream 106 to 123 tok/s, four streams 237 to 281) #4618, Inkling 2 Mini on Metal: a prompt's projections and sliding attention on the tensor units (a 45K prompt 906 to 1,634 tok/s) #4631, Inkling 2 Mini on Metal: a wide prompt chunk stages its convolution taps in the scratch (157.8 to 11.6 MiB a stream) #4644 and Inkling 2 Mini on Metal: the prompt kernel reads its key tiles from the cache on M5 (a round at 96K context 28.6 to 21.5 ms, a 45K prompt 1,892 to 2,078 tok/s) #4645 (a09f3e7d7). This pull request's own commit is84ab2c63f. It needs Inkling 2 Mini on Metal: routed experts on the M5 tensor units at every width (16 rows 49 to 36 ms, 64 rows 138 to 84 ms) #4523's tiles and Inkling 2 Mini on Metal: a wide prompt chunk stages its convolution taps in the scratch (157.8 to 11.6 MiB a stream) #4644's wide chunks; the rest of the stack is where it was measured.atc overlap --json: not run; ATC is not installed on the machine that pushes.The kernels.
ink2_units_t<FP8, GU>isink2_unitswith the tile turned: a threadgroup is 16 weight rows of one expert, and each simdgroup's op takes 32 of the expert's pairs, whereink2_unitstakes 32 weight rows by 16 pairs. The four entries aretf_ink2_{nvfp4,mxfp8}_{gu,down}_units_t. The decode of a weight block, the scale, the gate and the epilogue are the same code.Why the bits are the same. An output is one (pair, weight row) dot product. Both tiles accumulate it over the same 16-column steps in the same order with the same operands; the tile's orientation decides which outputs share an op, not an output's terms. So the width may choose between them, as #4523's rule allows only for kernels with one result: a row's sums still do not depend on the chunk it came in. Every served reply has the hash it had on #4645, among them the prompts that fill in 1,024-row chunks.
Who takes which.
experts.unitspicks by the call's rows: over 512, the turned tiles. Rounds, and prompt chunks beside other streams (256 rows at most since #4644), stay on #4523's tiles.experts.unitsTurnedasks for the turned tiles at any width, which is how the contract reaches them with small shapes.Checks on this head
84ab2c63f.zig build native -Dcpu=apple_m1: compiles.test-inkling2-metal-host,test-inkling2-host,test-inkling2-controls-host,test-inkling2-launch-map-host,test-inkling2-metal-capabilities,compile-inkling2-native-host): exit 0.tf-kernel-contract --only inkling2(-Doptimize=safe):SUMMARY 52 kernels: 52 pass gates 1-4, 0 fail, 0 known findings; 52 controls: 52 red as planted, 0 missed; 0 limit problems, exit 0. Four of the kernels and four of the controls are new: each turned entry against float64 on seven shapes, one of them 40 rows of one expert so that the pairs cross a 32-pair band, and its control (the NVFP4 factor doubled, the MXFP8 scale's exponent off by one) red at the first shape.zig fmt --check build.zig zigandgit diff --check: clean.zig build test test-goldenon this head (the stack's inherited failures are listed in Inkling 2 Mini on Metal: #4387's native build compiles, its norms write their output, and concurrent streams equal solo #4446). M1 to M4, which have no tensor units and never load these kernels. CUDA and HIP are not touched.Receipt
a09f3e7d7against this head.inkling2_loopMetal path, prompt chunks of more than 512 rows (a prompt filling alone).thinkingmachines/Inkling-2-Mini@ed40e7da625f594fc9c4990f5f66be24873c22d7,--parallel 4 --prompt-cache-gib 0. The served rows have Inkling 2 Mini DSpark on Metal: attention scale 1/sqrt(128), and the recurrent step reads kappa as FP32 #4447, Inkling 2 Mini DSpark on Metal: the hold in one command buffer, and drafts priced by the engine up to the whole block (one stream 44 to 97 tok/s on code, 4 streams 77 to 184-223) #4465, Inkling 2 Mini on Metal: a prompt-cache snapshot copies each key-value head's live rows, and the real-checkpoint serving tests run to it #4607, Inkling 2 Mini on Metal: with a drafter, the window fit prices a token at a token's bytes (a 64 GB limit holds the whole window for eight streams) #4622 and Inkling 2 Mini on Metal: a window's grammar masks step by the padded vocabulary, so a structured reply passes its second row #4635 at their current heads and Metal loader: a checkpoint span of 16 GiB or more loads (each pread capped at 1 GiB) #4435 applied.GPU time of a 1,024-row prompt chunk at 16K tokens of context, and of a 45K-token prompt in all (a development tree that is this stack with timing switches):
Served:
lane_bench.py--drafter--drafterThe decode rows do not reach the change (a round is at most a few dozen rows); they are there to show the build is otherwise the same. The drafted chat prompt's three repetitions were 96.1, 90.8 and 92.0.
bench_concurrent.py --alone --serial, four streams: 12 of 12 replies equal their solo runs, plain and with the drafter, and the serial check passes. The concurrency check's four replies and a three-turn chat with the prompt cache on and off have the hashes they had on Inkling 2 Mini on Metal: the prompt kernel reads its key tiles from the cache on M5 (a round at 96K context 28.6 to 21.5 ms, a 45K prompt 1,892 to 2,078 tok/s) #4645.Checklist
"draft": false, a resumed prompt equals a fresh one, and concurrent equals solo. (All three on this head, the resumed prompt with Inkling 2 Mini on Metal: a prompt-cache snapshot copies each key-value head's live rows, and the real-checkpoint serving tests run to it #4607 applied.)--drafter, no slower than without it. (Against Inkling 2 Mini on Metal: the prompt kernel reads its key tiles from the cache on M5 (a round at 96K context 28.6 to 21.5 ms, a 45K prompt 1,892 to 2,078 tok/s) #4645: prompts filling alone are faster, the rest unchanged.)